<template>
  <div class="home-hello">
    <div class="home-hello-left">
      <div>
        <div class="home-hello-title">HELLO，你好！{{ user.user.name }}</div>
        <div class="home-hello-sub-title">欢迎使用悦客服系统管理平台</div>
      </div>
      
      <div>
        <div class="home-hello-line"></div>
        <div class="home-hello-today">
          <span style="font-size: 15px;">今日，</span>
          <span>{{year}}年{{month}}月{{day}}日，</span>
          <span>星期{{ weekday }}</span>
        </div>
      </div>
    </div>
    <div class="home-hello-right">
      <div class="home-hello-tip">我的常用菜单</div>
      <div class="home-hello-tag-list">
        <div
          v-for="(item, index) in menus.allStarMenus"
          :key="index"
          class="home-hello-tag"
          @click="onClick(item)"
        >
          <i class="iconfont home-hello-icon" :class="[item.icon]"></i>
          {{ item.name }}
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import dayjs from 'dayjs';
import { useRouter, useRoute } from 'vue-router'
import { useUserStore } from '@/plugins/store'
import { useMenuStore } from '@/plugins/store'

const router = useRouter()
const route = useRoute()

const user = useUserStore()

const now = dayjs()
const year = now.year()
const month = now.month() + 1
const day = now.date()
const week = now.day()
const weekday = computed(() => {
  const s = '日一二三四五六'
  return s[week]
})

const menus = useMenuStore()

const onClick = item => {
  if (!item.url) {
    router.push({ name: 'Wip' })
    return
  }
  if (item.url !== route.name) {
    router.push({ name: item.url })
  }
}
</script>

<style scoped lang="scss">
.home-hello {
  height: 250px;
  background: #094DB2;
  border-radius: 4px;
  padding: 14px 17px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  &-left {
    width: 40%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  &-right {
    width: 50%;
    height: 100%;
    background: #FFFFFF;
    border-radius: 4px;
    padding: 10px 0 10px 10px;
    box-sizing: border-box;
  }

  &-title {
    font-family: PingFangSC-SNaNpxibold;
    font-weight: 600;
    font-size: 22px;
    color: #FFFFFF;
    letter-spacing: 0;
  }
  &-sub-title {
    font-family: PingFangSC-Medium;
    font-weight: 500;
    font-size: 15px;
    color: #B9D0FF;
    letter-spacing: 0;
    margin-top: 4px;
  }
  &-line {
    height: 50px;
    border-left: 1px solid #FFFFFF;
  }
  &-today {
    color: #b9d0ff;
    font-size: 12px;
    font-weight: 500;
    margin-top: 5px;
  }

  &-tip {
    font-family: PingFangSC-Medium;
    font-weight: 500;
    font-size: 14px;
    color: #333333;
  }

  &-tag-list {
    display: flex;
    flex-wrap: wrap;
  }
  &-tag {
    padding: 0 12px;
    height: 36px;
    background: #F5F7FA;
    border-radius: 4px;
    display: flex;
    align-items: center;
    font-family: PingFangSC-Regular;
    font-weight: 400;
    font-size: 13px;
    color: #333333;
    margin-top: 8px;
    margin-right: 8px;
    cursor: pointer;
  }
  &-icon {
    margin-right: 6px;
  }
}
</style>
